package com.ethan.blog.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ethan.blog.pojo.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 用户表;(user)表数据库访问层
 *
 * @author : Ethan
 * @date : 2024-5-24
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {
//    @AutoFill(OperationType.INSERT)
//    // todo: 详细设置加入方式
//    @Insert("INSERT INTO user(nick_name, account, email, phone_number, password, datebirth, permission_level, create_id, create_time, update_id, update_time, deleted) " +
//            "VALUES (#{nickName}, #{account}, #{email}, #{phoneNumber}, #{password}, #{datebirth}, #{permissionLevel}, #{createId}, #{createTime}, #{updateId}, #{updateTime}, #{deleted})"
//    )
//    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = long.class)
//    void insertUser(User user);

    @Select("SELECT * FROM user WHERE account = #{accountOrPhoneNumberOrEmail} OR phone_number = #{accountOrPhoneNumberOrEmail} OR email = #{accountOrPhoneNumberOrEmail}")
    User getByAccountOrPhoneOrEmail(String accountOrPhoneNumberOrEmail);
}